<?php

namespace app\admin\controller\wanlshop;

use app\common\controller\Backend;
use think\Db;
use Exception;
use think\exception\DbException;
use think\exception\PDOException;
use think\exception\ValidateException;
/**
 * 验证码原图
 *
 * @icon fa fa-circle-o
 */
class PayIntegral extends Backend
{

    /**
     * Captcha模型对象
     * @var \app\admin\model\wanlshop\Captcha
     */
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\wanlshop\PayIntegral;

    }


    public function index()
    {

        //当前是否为关联查询
        $this->relationSearch = true;
        //设置过滤方法
        $this->request->filter(['strip_tags', 'trim']);
        if ($this->request->isAjax())
        {
            //如果发送的来源是Selectpage，则转发到Selectpage
            if ($this->request->request('keyField'))
            {
                return $this->selectpage();
            }
            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
            $total = $this->model
                ->where($where)

                ->count();

            $list = $this->model
                ->where($where)

                ->limit($offset, $limit)
                ->select();
            $list = collection($list)->toArray();
            $result = array("total" => $total, "rows" => $list);

            return json($result);
        }
        return $this->view->fetch();
    }


    /**
     * 清空全部
     *
     * @return string|Json
     * @throws \think\Exception
     * @throws DbException
     */
    public function clear()
    {
        //设置过滤方法
        $row = model('app\admin\model\wanlshop\CaptchaLog')
            ->where('id','egt',1)
            ->delete();
        if($row){
            $this->success();
        }else{
            $this->error('网络异常清空失败');
        }
    }



}